package t4tools.splittingObjects.config;

import java.util.Arrays;
import java.util.List;

public class CompoundPropertyColumnConfig {

	private String key;

	private boolean repeatable;

	private List<String> properties;

	public CompoundPropertyColumnConfig(String key, boolean repeatable, String... properties) {
		this.key = key;
		this.repeatable = repeatable;
		this.properties = Arrays.asList(properties);
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public boolean isRepeatable() {
		return repeatable;
	}

	public void setRepeatable(boolean repeatable) {
		this.repeatable = repeatable;
	}

	public List<String> getProperties() {
		return properties;
	}

	public void setProperties(List<String> properties) {
		this.properties = properties;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((key == null) ? 0 : key.hashCode());
		result = prime * result + ((properties == null) ? 0 : properties.hashCode());
		result = prime * result + (repeatable ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		CompoundPropertyColumnConfig other = (CompoundPropertyColumnConfig) obj;
		if (key == null) {
			if (other.key != null) {
				return false;
			}
		} else if (!key.equals(other.key)) {
			return false;
		}
		if (properties == null) {
			if (other.properties != null) {
				return false;
			}
		} else if (!properties.equals(other.properties)) {
			return false;
		}
		if (repeatable != other.repeatable) {
			return false;
		}
		return true;
	}

}
